<template>
	<view class="content">
		<view class="passwordform">
			<u--form labelPosition="left" :model="passwordForm" :rules="rules" ref="uForm">
				<u-form-item label="结算方式" prop="bank_type" labelWidth="80px" class="itemform">
					<view @click="show = true" style="text-align: right;display: flex;justify-content: end;">{{settlementTxt}}<text class="iconfont icon-xiangyoujiantou"></text> </view>
				</u-form-item>
				<u-form-item label="账号" prop="banknumber" labelWidth="80px" class="itemform">
					<u--input v-model="passwordForm.banknumber" border="none" placeholder="请确认账号" ></u--input>
				</u-form-item>
				<u-form-item label="姓名" prop="busername" labelWidth="80px" class="itemform">
					<u--input v-model="passwordForm.busername" border="none" placeholder="请输入姓名" ></u--input>
				</u-form-item>
				<u-form-item label="银行名称" v-if="passwordForm.bank_type == 1" prop="bankname" labelWidth="80px" class="itemform">
					<u--input v-model="passwordForm.bankname" border="none" placeholder="请确认银行名称" ></u--input>
				</u-form-item>
				<u-form-item label="开户支行" v-if="passwordForm.bank_type == 1" prop="branch" labelWidth="80px" class="itemform">
					<u--input v-model="passwordForm.branch" border="none" placeholder="请输入开户支行" ></u--input>
				</u-form-item>
				<u-form-item label="昵称" v-if="passwordForm.bank_type == 2" prop="nickname" labelWidth="80px" class="itemform">
					<u--input v-model="passwordForm.nickname" border="none" placeholder="请输入昵称" ></u--input>
				</u-form-item>
				<u-form-item label="银行名称" v-if="passwordForm.bank_type == 2" prop="bankname" labelWidth="80px" class="itemform">
					<u--input v-model="passwordForm.bankname" border="none" placeholder="请确认银行名称" ></u--input>
				</u-form-item>
			</u--form>
			<text class="current2" v-if="passwordForm.bank_type == 2">提示：系统会自动为本账户匹配押金范围内的订单金额，单张卡1天公娃娃脸匹配100次，
			 <text>押金低于180USDT ,将不会进和地订单匹配</text> </text>
			<u-action-sheet :actions="list" :closeOnClickOverlay="true" :closeOnClickAction="true"  title="请选择结算方式" :show="show" @close="closeActionSheet" @select="selectActionSheet"></u-action-sheet>
			
			<view class="colltitle">USDT搬砖收益说明:</view>
			<view class="form_txt">1、银行卡押金匹配订单金额;</view>
			<view class="form_txt">2、自动匹配接近金额;</view>
			<view class="form_txt">3、平台收取2%服务费;</view>
			<view class="form_txt">4、匹配模式收益根据市场行情在10-20%以上不等，最低收益10%以上;</view>
			<view class="form_txt">5、邀请好友卖USDT可额外赚取好友所产生平台收益一级30%,二级15%，级5%收益。</view>
			<u-button type="primary" color="#53c393" style="margin-top: 20rpx;" text="确认添加" @click="copyMoney"></u-button>
		</view>
		
		
		
		
		<u-toast ref="uToast" duration="1000"></u-toast>
		<botLine />
	</view>
</template>

<script>
	import botLine from '../../components/botLine.vue'
	export default {
		components:{
			botLine
		},
		data() {
			return {
				show : false,
				settlementTxt : '请选择结算方式',
				current : null,
				list: [{name:'银行卡',id : 1},{name: '数字人民币',id : 2}],
				passwordForm : {
					uid : '',
					type : 1, 			//1添加  2修改
					bid : null,			//修改时卡片id
					bank_type : '',		//结算方式   1|| 2
					banknumber : '',  	//账号
					busername : '',		//姓名
					bankname : '',		//银行名称 
					branch : '',		//开户支行
					nickname : '', 		//数字人民币：昵称
					
				},
				rules : {
					bank_type:[
						{ required: true,validator: function(rule, value, callback){
							if (value == '') {
								callback(new Error('请选择结算方式'))
							} else {
								callback()
							}
						}, trigger: ['blur','change'] }
					],
					banknumber:[{ required: true, message: '请输入结算账号', trigger: ['blur','change'] }],
					busername:[{ required: true, message: '请输入姓名', trigger: ['blur','change'] }],
					bankname:[{ required: true, message: '请输入银行名称', trigger: ['blur','change'] }],
					branch:[{ required: true, message: '请输入开户支行', trigger: ['blur','change'] }],
					nickname:[{ required: true, message: '请输入昵称', trigger: ['blur','change'] }]
				}
				
			}
		},
		onLoad() {
			let cookies = JSON.parse(localStorage.getItem("cookies"))
			this.passwordForm.uid = cookies[0].uid;
		},
		methods: {
			copyMoney(){
				let _this = this
				console.log(this.passwordForm)
				this.$refs.uForm.validate().then(res =>{
					if(res){
						uni.request({
							url:'/index/api/add_card',
							method:'post',
							data:this.passwordForm,
							success:res=>{
								this.$refs.uToast.show({
									type: 'default',
									title: '默认主题',
									message: "添加成功",
									complete(){
										if(this.$route.query.type == 'info'){
											uni.navigateTo({
												url:`/pages/indexinfo/index?pid=${_this.$route.query.pid}`
											});
										}else if(this.$route.query.type == 'center'){
											uni.navigateTo({
												url:`/pages/addcollection/index`
											});
										}
										
										
										
									}
								})
								
							}
						})
					}
				}).catch(error=>{
					
				})
			},
			closeActionSheet(){this.show = false;},
			selectActionSheet(v){
				console.log(v)
				this.settlementTxt = v.name;
				this.passwordForm.bank_type = v.id;
			}
			
			
		}
	}
</script>

<style lang="scss" scoped>
.content{padding:0 20rpx ;
	height: 100vh;background-color: #f1f5f8;
	.passwordform{
		padding-top: 20rpx;
		.itemform{
			margin-bottom:20rpx;font-weight: 400;
			/deep/.u-form-item__body{
				background-color: #fff;padding-left:10rpx;padding-right:10rpx;
			}
		}
		.current2{
			font-size: 24rpx;color: #94989b;
			text{color: #f9855e;}
		}
	}
	.colltitle{
		color: #000;font-size: 30rpx;padding:20rpx 0 10rpx 0;
	}
	.form_txt{
		font-size: 24rpx;color: #94989b;line-height: 46rpx;
	}
/deep/.u-form-item__body__right__content__slot{justify-content: flex-end;}	
	
	
	
	
	
}
</style>